Final (?) pass at moving core geocaching structures to QStrings.
authorrobertlipe <robertlipe@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Sat, 30 Mar 2013 05:14:51 +0000 (05:14 +0000)
committerrobertlipe <robertlipe@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Sat, 30 Mar 2013 05:14:51 +0000 (05:14 +0000)
git-svn-id: http://gpsbabel.googlecode.com/svn/trunk@4370 f51c46e8-681c-474f-0cfe-069cfd0219fb

16 files changed:
gpsbabel/an1.cc
gpsbabel/cetus.cc
gpsbabel/csv_util.cc
gpsbabel/defs.h
gpsbabel/delbin.cc
gpsbabel/geo.cc
gpsbabel/geoniche.cc
gpsbabel/html.cc
gpsbabel/kml.cc
gpsbabel/maggeo.cc
gpsbabel/palmdoc.cc
gpsbabel/src/core/datetime.h
gpsbabel/text.cc
gpsbabel/unicsv.cc
gpsbabel/vcf.cc
gpsbabel/waypt.cc

index 458afbba963702bd26ba221f62b686c192ec1394..480f29a413fd35e36938db36a2325eb9db24989e 100644 (file)
@@ -769,9 +769,9 @@ Write_One_AN1_Waypoint(const waypoint* wpt)
   rec->name = xstrdup(wpt->description);
 
   if (!nogc && wpt->gc_data->id) {
-    char* extra = (char*) xmalloc(25 + strlen(wpt->gc_data->placer) + strlen(wpt->shortname));
+    char* extra = (char*) xmalloc(25 + strlen(wpt->gc_data->placer.toUtf8().data()) + strlen(wpt->shortname));
     sprintf(extra, "\r\nBy %s\r\n%s (%1.1f/%1.1f)",
-            wpt->gc_data->placer,
+            wpt->gc_data->placer.toUtf8().data(),
             wpt->shortname, wpt->gc_data->diff/10.0,
             wpt->gc_data->terr/10.0);
     rec->name = xstrappend(rec->name, extra);
index bf646f00c8087b6e8f7606a0a456a4470a8eac6b..0e3925ca4e4be1952815b4d11650fb68615bbe4f 100644 (file)
@@ -505,7 +505,7 @@ cetus_writewpt(const waypoint* wpt)
               "" : " (Disabled)",
               wpt->gc_data->is_archived==status_true ?
               " (Archived)" : "",
-              wpt->gc_data->placer,
+              wpt->gc_data->placer.toUtf8().data(),
               gs_get_cachetype(wpt->gc_data->type),
               gs_get_container(wpt->gc_data->container),
               wpt->gc_data->diff/10.0,
@@ -557,8 +557,8 @@ cetus_writewpt(const waypoint* wpt)
   }
   vdata += strlen(vdata) + 1;
 
-  if (wpt->gc_data->hint) {
-    char* hint = xstrdup(wpt->gc_data->hint);
+  if (!wpt->gc_data->hint.isEmpty()) {
+    char* hint = xstrdup(wpt->gc_data->hint.toUtf8().data());
     rec->type = WptCache;
     strncpy(vdata, hint, NOTESZ + 1) ;
     xfree(hint);
index 90456a4f98e13dbd3b7f8fd836c1805f4dcb72be..ff6311e81bd05eef08d5946a50801f9c3eded891 100644 (file)
@@ -2001,12 +2001,12 @@ xcsv_waypt_pr(const waypoint* wpt)
       field_is_unknown = wpt->gc_data->type == gt_unknown;
       break;
     case XT_GEOCACHE_HINT:
-      writebuff(buff, fmp->printfc, NONULL(wpt->gc_data->hint));
-      field_is_unknown = !wpt->gc_data->hint;
+      writebuff(buff, fmp->printfc, wpt->gc_data->hint.toUtf8().data());
+      field_is_unknown = !wpt->gc_data->hint.isEmpty();
       break;
     case XT_GEOCACHE_PLACER:
-      writebuff(buff, fmp->printfc, NONULL(wpt->gc_data->placer));
-      field_is_unknown = !wpt->gc_data->placer;
+      writebuff(buff, fmp->printfc, wpt->gc_data->placer.toUtf8().data());
+      field_is_unknown = !wpt->gc_data->placer.isEmpty();
       break;
     case XT_GEOCACHE_ISAVAILABLE:
       if (wpt->gc_data->is_available == status_false) {
index 8a709b20d0acfabaf72c52ffb6d3323f15c068f4..fb635a98fa2bf30a78efd24b3990d075c8365452 100644 (file)
@@ -283,11 +283,8 @@ class geocache_data {
     has_customcoords(status_unknown),
     exported(0),
     last_found(0),
-    placer(NULL),
     placer_id(0),
-    hint(NULL),
-    favorite_points(0),
-    personal_note(NULL)
+    favorite_points(0)
   {}
   int id; /* The decimal cache number */
   geocache_type type:5;
@@ -300,13 +297,13 @@ class geocache_data {
   status_type has_customcoords:2;
   time_t exported;
   time_t last_found;
-  char* placer; /* Placer name */
+  QString placer; /* Placer name */
   int placer_id; /* Placer id */
-  char* hint; /* all these UTF8, XML entities removed, May be not HTML. */
+  QString hint; /* all these UTF8, XML entities removed, May be not HTML. */
   utf_string desc_short;
   utf_string desc_long;
   int favorite_points;
-  char* personal_note;
+  QString personal_note;
 };
 
 typedef struct xml_tag {
index 7846c44675b62ab18e887962bc7fb764ce90ead6..aabd1a1de79db821f0d7a19ef5ffb3eafc6bada1 100644 (file)
@@ -1191,8 +1191,8 @@ get_gc_notes(const waypoint* wp, int* symbol, char** notes, unsigned* notes_size
   }
   if (wp->description) {
     gbfputs(wp->description, fd);
-    if (wp->gc_data->placer) {
-      gbfprintf(fd, " by %s", wp->gc_data->placer);
+    if (!wp->gc_data->placer.isEmpty()) {
+      gbfprintf(fd, " by %s", wp->gc_data->placer.toUtf8().data());
     }
     gbfputc('\n', fd);
   }
@@ -1243,8 +1243,8 @@ get_gc_notes(const waypoint* wp, int* symbol, char** notes, unsigned* notes_size
   } else {
     gbfprintf(fd, "/T%u\n", wp->gc_data->terr / 10);
   }
-  if (wp->gc_data->hint && !opt_hint_at_end) {
-    gbfprintf(fd, "HINT: %s\n", wp->gc_data->hint);
+  if (!wp->gc_data->hint.isEmpty() && !opt_hint_at_end) {
+    gbfprintf(fd, "HINT: %s\n", wp->gc_data->hint.toUtf8().data());
   }
   if (!wp->gc_data->desc_short.utfstring.isEmpty() || !wp->gc_data->desc_long.utfstring.isEmpty()) {
     gbfputs("DESC: ", fd);
@@ -1298,8 +1298,8 @@ get_gc_notes(const waypoint* wp, int* symbol, char** notes, unsigned* notes_size
       gbfputc('\n', fd);
     }
   }
-  if (wp->gc_data->hint && opt_hint_at_end) {
-    gbfprintf(fd, "\nHINT: %s\n", wp->gc_data->hint);
+  if (!wp->gc_data->hint.isEmpty() && opt_hint_at_end) {
+    gbfprintf(fd, "\nHINT: %s\n", wp->gc_data->hint.toUtf8().data());
   }
   gbfputc(0, fd);
   *notes_size = fd->memlen;
index 09d1c9235baaa210e11de90f3e04d0b88e810832..d72508243f8254ef1248324d81c68ddc95bfb004 100644 (file)
@@ -250,7 +250,8 @@ void wpt_name(const char* args, const char** unused)
   wpt_tmp->description = xstrappend(wpt_tmp->description,args);
   s = xstrrstr(wpt_tmp->description, " by ");
   if (s) {
-    waypt_alloc_gc_data(wpt_tmp)->placer = xstrdup(s + 4);
+    waypt_alloc_gc_data(wpt_tmp);
+    wpt_tmp->gc_data->placer = xstrdup(s + 4);
 
     if (nuke_placer) {
       // Sleaze alert.  We're casting away constness and writing into a string
index 88e347d2d4fe73ba304a336bc9c93b6bd667c085..482e76a14cae82a80e7081fc31c2b35c7c4dab72 100644 (file)
@@ -685,7 +685,7 @@ geoniche_geostuff(const waypoint* wpt)
     return NULL;
   }
 
-  snprintf(tbuf, sizeof(tbuf), "\n%s by %s\n\n", gs_get_cachetype(wpt->gc_data->type), wpt->gc_data->placer);
+  snprintf(tbuf, sizeof(tbuf), "\n%s by %s\n\n", gs_get_cachetype(wpt->gc_data->type), wpt->gc_data->placer.toUtf8().data());
   gs = xstrappend(gs, tbuf);
 
   /*
index f24c57f951735f8a41a04b34fc3c6a8ee10ec63a..c0764471d5d0fc6418482cce600778a4e4f45240 100644 (file)
@@ -115,8 +115,8 @@ html_disp(const waypoint* wpt)
     } else {
       gbfprintf(file_out, "%s", wpt->description);
     }
-    if (wpt->gc_data->placer) {
-      gbfprintf(file_out, " by %s", wpt->gc_data->placer);
+    if (!wpt->gc_data->placer.isEmpty()) {
+      gbfprintf(file_out, " by %s", wpt->gc_data->placer.toUtf8().data());
     }
   }
   gbfprintf(file_out, "</p></td>\n");
@@ -144,12 +144,12 @@ html_disp(const waypoint* wpt)
     gbfprintf(file_out, "<p class=\"gpsbabeldesclong\">%s</p>\n", tmpstr);
     xfree(tmpstr);
   }
-  if (wpt->gc_data->hint) {
+  if (!wpt->gc_data->hint.isEmpty()) {
     char* hint = NULL;
     if (html_encrypt) {
       hint = rot13(wpt->gc_data->hint);
     } else {
-      hint = xstrdup(wpt->gc_data->hint);
+      hint = xstrdup(wpt->gc_data->hint.toUtf8().data());
     }
     gbfprintf(file_out, "<p class=\"gpsbabelhint\"><strong>Hint:</strong> %s</p>\n", hint);
     xfree(hint);
index 6a1f4c1c778f0322e413bbb7b918adb41aedf2b9..62c9c5be965b9fb2404348e3ba48f64891c3ee4c 100644 (file)
@@ -1477,7 +1477,7 @@ static void kml_geocache_pr(const waypoint* waypointp)
     kml_write_data_element("gc_name", waypointp->url_link_text);
   }
 
-  if (waypointp->gc_data->placer) {
+  if (!waypointp->gc_data->placer.isEmpty()) {
     kml_write_data_element("gc_placer", waypointp->gc_data->placer);
   }
 
index 912d42bb459925fea97eac5fe2ee11966564b442..1eecc0c10f05f361dcf392d0ddd0e3e40cae9082 100644 (file)
@@ -270,7 +270,7 @@ maggeo_waypt_pr(const waypoint* waypointp)
   char* shortname;
   char* cname = NULL;
   const char* ctype = NULL;
-  char* placer = NULL;
+  QString placer;
   char* lfounddate = NULL;
   char* placeddate = NULL;
 
@@ -324,8 +324,8 @@ maggeo_waypt_pr(const waypoint* waypointp)
            0 : waypointp->altitude);
   append(obuf, shortname);
   append(obuf, cname);
-  append(obuf, placer);
-  append(obuf, waypointp->gc_data->hint);
+  append(obuf, placer.toUtf8().data());
+  append(obuf, waypointp->gc_data->hint.toUtf8().data());
   append(obuf, ctype);
   append(obuf, placeddate);
   append(obuf, lfounddate);
index 43c820a6f89b7be33d8ff91ad36670942baa23aa..40497956694706650a7b40b6cc73ad201046c36d 100644 (file)
@@ -464,12 +464,12 @@ palmdoc_disp(const waypoint *wpt)
       docprintf(10+strlen(stripped_html), "\n%s\n", stripped_html);
       xfree(stripped_html);
     }
-    if (wpt->gc_data->hint) {
+    if (!wpt->gc_data->hint.isEmpty()) {
       char *hint = NULL;
       if (palm_encrypt) {
         hint = rot13(wpt->gc_data->hint);
       } else {
-        hint = xstrdup(wpt->gc_data->hint);
+        hint = xstrdup(wpt->gc_data->hint.toUtf8().data());
       }
       docprintf(10+strlen(hint), "\nHint: %s\n", hint);
       xfree(hint);
index 9aad0368db11c2a5f81736274ba9f561830aeba6..709da22d415bb18ba329ba8fd8dc8a8cde12b20a 100644 (file)
@@ -44,6 +44,7 @@ public:
   }
 
   DateTime(QDate date, QTime time) : QDateTime(date, time) { }
+  DateTime(QDateTime dt) : QDateTime(dt) { }
 
 
   // Handle time_tm tm = wpt->creation_time;
index 7a65a66f19bf9dbc6c0801c90c733317d6eeec9c..ef2cd59c192dbb48129455d2d00d51965a618a1c 100644 (file)
@@ -143,8 +143,8 @@ text_disp(const waypoint *wpt)
 
   if (strcmp(wpt->description, wpt->shortname)) {
     gbfprintf(file_out, "%s", wpt->description);
-    if (wpt->gc_data->placer) {
-      gbfprintf(file_out, " by %s", wpt->gc_data->placer);
+    if (!wpt->gc_data->placer.isEmpty()) {
+      gbfprintf(file_out, " by %s", wpt->gc_data->placer.toUtf8().data());
     }
   }
   if (wpt->gc_data->terr) {
@@ -162,12 +162,12 @@ text_disp(const waypoint *wpt)
       gbfprintf(file_out, "\n%s\n", stripped_html);
       xfree(stripped_html);
     }
-    if (wpt->gc_data->hint) {
+    if (!wpt->gc_data->hint.isEmpty()) {
       char *hint = NULL;
       if (txt_encrypt) {
         hint = rot13(wpt->gc_data->hint);
       } else {
-        hint = xstrdup(wpt->gc_data->hint);
+        hint = xstrdup(wpt->gc_data->hint.toUtf8().data());
       }
       gbfprintf(file_out, "\nHint: %s\n", hint);
       xfree(hint);
index d4d3a1ac7a4b6ab256f880ab5bdc2330e59f7ba8..bd7f83ffad351a44ceb20e5b6238f5f0d65e31aa 100644 (file)
@@ -1479,13 +1479,13 @@ unicsv_waypt_enum_cb(const waypoint *wpt)
     if (gc_data->last_found) {
       gb_setbit(&unicsv_outp_flags, fld_gc_last_found);
     }
-    if (gc_data->placer && *gc_data->placer) {
+    if (!gc_data->placer.isEmpty()) {
       gb_setbit(&unicsv_outp_flags, fld_gc_placer);
     }
     if (gc_data->placer_id) {
       gb_setbit(&unicsv_outp_flags, fld_gc_placer_id);
     }
-    if (gc_data->hint && *gc_data->hint) {
+    if (!gc_data->hint.isEmpty()) {
       gb_setbit(&unicsv_outp_flags, fld_gc_hint);
     }
   }
index 7c503198d92c2a4807cae081ddb7638a5c473b7b..9c76a6359584fa491eccdc3efc136aa39f474517 100644 (file)
@@ -118,7 +118,7 @@ vcf_disp(const waypoint *wpt)
     vcf_print(s);
     xfree(s);
   } else {
-    vcf_print(wpt->gc_data->hint);
+    vcf_print(wpt->gc_data->hint.toUtf8().data());
   }
 
   gbfprintf(file_out, "\nEND:VCARD\n");
index 2106a97fe1c19382f7a7eb006031b10bcb22746f..6dbfaa3a7756e41d90c699910a66bb138bdcfc1d 100644 (file)
@@ -91,21 +91,14 @@ waypt_dupe(const waypoint *wpt)
     tmp->gc_data->exported = wpt->gc_data->exported;
     tmp->gc_data->last_found = wpt->gc_data->last_found;
     tmp->gc_data->placer_id = wpt->gc_data->placer_id;
+    tmp->gc_data->desc_short.utfstring = wpt->gc_data->desc_short.utfstring;
     tmp->gc_data->desc_short.is_html = wpt->gc_data->desc_short.is_html;
+    tmp->gc_data->desc_long.utfstring = wpt->gc_data->desc_long.utfstring;
     tmp->gc_data->desc_long.is_html = wpt->gc_data->desc_long.is_html;
     tmp->gc_data->favorite_points = wpt->gc_data->favorite_points;
-    tmp->gc_data->desc_short.utfstring = wpt->gc_data->desc_short.utfstring;
-    tmp->gc_data->desc_long.utfstring = wpt->gc_data->desc_long.utfstring;
-
-    if (wpt->gc_data->placer) {
-      tmp->gc_data->placer = xstrdup(wpt->gc_data->placer);
-    }
-    if (wpt->gc_data->hint) {
-      tmp->gc_data->hint = xstrdup(wpt->gc_data->hint);
-    }
-    if (wpt->gc_data->personal_note) {
-      tmp->gc_data->personal_note = xstrdup(wpt->gc_data->personal_note);
-    }
+    tmp->gc_data->placer = wpt->gc_data->placer;
+    tmp->gc_data->hint = wpt->gc_data->hint;
+    tmp->gc_data->personal_note = wpt->gc_data->personal_note;
   }
 
   /*
@@ -419,15 +412,6 @@ waypt_free(waypoint *wpt)
   if (wpt->gc_data != &empty_gc_data) {
     geocache_data *gc_data = (geocache_data *)wpt->gc_data;
 
-    if (gc_data->placer) {
-      xfree(gc_data->placer);
-    }
-    if (gc_data->hint) {
-      xfree(gc_data->hint);
-    }
-    if (gc_data->personal_note) {
-      xfree(gc_data->personal_note);
-    }
     delete gc_data;
   }
   fs_chain_destroy(wpt->fs);